﻿#region

using System.Collections.Generic;
using YouTubePlaylist.Libraries;
using YouTubePlaylist.Models;
using YouTubePlaylist.MusicVideoService;

#endregion

namespace YouTubePlaylist.Adapters
{
    public class LogMessageAdapter
    {
        #region Private fields
        private readonly LogMessage _msg;
        #endregion

        public LogMessageAdapter(LogMessage msg)
        {
            _msg = msg;
        }

        public long FacebookTemplateId
        {
            get
            {
                switch (_msg.Command)
                {
                    case "AddPlaylist":
                        return 221117020248;
                    case "AddTrack":
                        return 221131420248;
                    //case "CopyPlaylist":
                    //case "DeletePlaylist":
                    //case "DeleteTrackFromPlaylist":
                    //case "RefreshTrack":
                    //case "SaveTrackUrl":
                    default:
                        return 0;
                }
            }
        }

        public IDictionary<string, string> FacebookTemplateData
        {
            get
            {
                var data = new Dictionary<string, string>();
                switch (_msg.Command)
                {
                    case "AddPlaylist":
                        {
                            VideoPlaylist vp = DataLayer.Singleton.GetPlaylist(_msg.Parameters[0], null);
                            if (vp != null)
                            {
                                data["playlist"] = vp.Name;
                                data["playlist-url"] = MailClient.GetLink(vp);
                            }
                        }
                        break;
                    case "AddTrack":
                        {
                            VideoPlaylist vp = DataLayer.Singleton.GetPlaylist(_msg.Parameters[0], null);
                            VideoTrack vt = DataLayer.Singleton.GetTrack(_msg.Parameters[1], null);
                            if (vp != null && vt != null)
                            {
                                data["artist"] = vt.Artist;
                                data["track"] = vt.Name;
                                data["track-url"] = MailClient.GetLink(vp, vt);
                                data["playlist"] = vp.Name;
                                data["playlist-url"] = MailClient.GetLink(vp);
                            }
                        }
                        break;
                    //case "CopyPlaylist":
                    //case "DeletePlaylist":
                    //case "DeleteTrackFromPlaylist":
                    //case "RefreshTrack":
                    //case "SaveTrackUrl":
                }
                return data;
            }
        }
    }
}